/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CosBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Cos;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CopyCos
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 43 */     ZimbraSoapContext lc = getZimbraSoapContext(context);
/* 44 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 46 */     String destCosName = request.getElement("name").getText().toLowerCase();
/* 47 */     Element srcCosElem = request.getElement("cos");
/* 48 */     String srcCosNameOrId = srcCosElem.getText();
/* 49 */     Key.CosBy srcCosBy = Key.CosBy.fromString(srcCosElem.getAttribute("by"));
/*    */     
/* 51 */     Cos srcCos = prov.get(srcCosBy, srcCosNameOrId);
/* 52 */     if (srcCos == null) {
/* 53 */       throw AccountServiceException.NO_SUCH_COS(srcCosNameOrId);
/*    */     }
/* 55 */     checkRight(lc, context, null, Rights.Admin.R_createCos);
/* 56 */     checkRight(lc, context, srcCos, Rights.Admin.R_getCos);
/*    */     
/* 58 */     Cos cos = prov.copyCos(srcCos.getId(), destCosName);
/*    */     
/* 60 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CopyCos", "name", destCosName, "cos", srcCosNameOrId }));
/*    */     
/*    */ 
/* 63 */     Element response = lc.createElement(AdminConstants.COPY_COS_RESPONSE);
/* 64 */     GetCos.encodeCos(response, cos);
/*    */     
/* 66 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 71 */     relatedRights.add(Rights.Admin.R_createCos);
/* 72 */     relatedRights.add(Rights.Admin.R_getCos);
/* 73 */     notes.add("Need the " + Rights.Admin.R_getCos.getName() + " right on the source cos.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CopyCos.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */